/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2017 All Rights Reserved.
 */
package com.ge.utils;

import com.ge.modules.entity.*;

import java.lang.reflect.Method;

/**
 *
 * @author wb-tby290972
 * @version $Id: ConvertVo.java, v 0.1 2017年09月21日 10:39 wb-tby290972 Exp $
 */
public class ConvertVo {
    /**
     * 为一个domain对象
     * 生成转换vo对象的代码模板
     */
    public void conver(Class vo){
        String name = vo.getSimpleName();
        String varName = name.toLowerCase();//变量名称
        String line1=name+" "+ varName +"="+"new "+name+"();";
        Method[] methods = vo.getMethods();
        System.out.println(line1);
        for (Method method:methods){
            String methodName = method.getName();
            if (!methodName.startsWith("set"))
                continue;
            String fileName=methodName.substring(3,methodName.length());
            String firstChar = String.valueOf(fileName.charAt(0));
            fileName = fileName.replace(firstChar, String.valueOf(firstChar).toUpperCase());
            String line=varName+"."+methodName+"(this.get"+fileName+"());";
            System.out.println(line);
        }
        System.out.println("return "+varName+";");
    }

    public static void main(String[] args) {
        ConvertVo convertVo=new ConvertVo();
        convertVo.conver(TbStoreEntity.class);
    }
}